package org.codefinger.json.test;

import java.io.IOException;
import java.io.InputStreamReader;

public class Util {

	public static String loadClassPathResource(String classpath) {
		InputStreamReader reader = new InputStreamReader(
				ClassLoader.getSystemResourceAsStream(classpath));

		char[] buffer = new char[1024];
		StringBuilder builder = new StringBuilder(1024);

		try {
			int offset = reader.read(buffer);
			while (offset != -1) {
				builder.append(buffer, 0, offset);
				offset = reader.read(buffer);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

		return builder.toString();

	}

}
